export interface DictionaryState {
  specialSubjectType?:
    | [
        {
          key?: string;
          value?: string;
          introduce?: string;
        }
      ]
    | [];
  stuGrade?:
    | [
        {
          key?: string;
          value?: string;
          introduce?: string;
        }
      ]
    | [];
  stuClass?:
    | [
        {
          key?: string;
          value?: string;
          introduce?: string;
        }
      ]
    | [];
  courseType?:
    | [
        {
          key?: string;
          value?: string;
          introduce?: string;
        }
      ]
    | [];
  semester?:
    | [
        {
          key?: string;
          value?: string;
          introduce?: string;
        }
      ]
    | [];
  courseSystemType?:
    | [
        {
          key?: string;
          value?: string;
          introduce?: string;
        }
      ]
    | [];
}

const initialState: DictionaryState = {
  specialSubjectType: [],
  stuGrade: [],
  stuClass: [],
  courseType: [],
  semester: [],
  courseSystemType: [],
};

export default function dictionary(state = initialState, action) {
  switch (action.type) {
    case 'update-dictionary': {
      const {
        specialSubjectType,
        stuGrade,
        stuClass,
        courseType,
        semester,
        courseSystemType,
      } = action.payload;
      return {
        ...state,
        specialSubjectType,
        stuGrade,
        stuClass,
        courseType,
        semester,
        courseSystemType,
      };
    }
    case 'update-special-subject-type': {
      const { specialSubjectType } = action.payload;
      return {
        ...state,
        specialSubjectType,
      };
    }
    default:
      return state;
  }
}
